package translator.objects;

import java.io.PrintStream;

public abstract class Entity {

	private String ident;
	private String name;

	public Entity() {}
	
	/**
	 * @param ident
	 */
	public Entity(String ident) {
		this.ident = ident.replace("\"", "");
	}
	
	public Entity(String ident, String name) {
		this.ident = ident.replace("\"", "");
		this.name = name.replace("\"", "");
	}
		

	public String getIdent() {
		return this.ident;
	}
	
	public String getName() {
		return this.name;
	}
	
	public String getPackage() {
		return convertCamelCase(this.name);
	}
	
	public String getNID() {
		return this.name + "_" + this.ident;
	}

	public abstract void generateCode(PrintStream fo) ;

	private String convertCamelCase(String s) {
		   return s.replaceAll(
		      String.format("%s|%s|%s",
		         "(?<=[A-Z])(?=[A-Z][a-z])",
		         "(?<=[^A-Z])(?=[A-Z])",
		         "(?<=[A-Za-z])(?=[^A-Za-z])"
		      ),
		      " "
		   ).replace(' ', '_').toLowerCase();
		}
	
}